from game import Game
import pygame

class Portal_mini1:
    def __init__(self, left: int, top: int):
        self.image0 = pygame.image.load("Img/传送门2.png")
        self.image = pygame.transform.scale(self.image0, (50, 100))
        self.rect = self.image.get_rect()
        self.rect.left = left
        self.rect.top = top

    def portal_display(self):
        Game.window.blit(self.image, self.rect)

    def portal_hit_player(self):
        if self.rect.colliderect(Game.player1.rect):
            if Game.direction == "left":
                Game.player1.rect.x = Game.mini_portal2.rect.x - 50
                Game.player1.rect.y = Game.mini_portal2.rect.y - 30
            if Game.direction == "right":
                Game.player1.rect.x = Game.mini_portal2.rect.x + 50
                Game.player1.rect.y = Game.mini_portal2.rect.y - 30

        if self.rect.colliderect(Game.player2.rect):
            if Game.direction2 == "left":
                Game.player2.rect.x = Game.mini_portal2.rect.x - 50
                Game.player2.rect.y = Game.mini_portal2.rect.y - 30
            if Game.direction2 == "right":
                Game.player2.rect.x = Game.mini_portal2.rect.x + 50
                Game.player2.rect.y = Game.mini_portal2.rect.y - 30

        if self.rect.colliderect(Game.player3.rect):
            if Game.direction3 == "left":
                Game.player3.rect.x = Game.mini_portal2.rect.x - 50
                Game.player3.rect.y = Game.mini_portal2.rect.y - 30
            if Game.direction3 == "right":
                Game.player3.rect.x = Game.mini_portal2.rect.x + 50
                Game.player3.rect.y = Game.mini_portal2.rect.y - 30

        if self.rect.colliderect(Game.player4.rect):
            if Game.direction4 == "left":
                Game.player4.rect.x = Game.mini_portal2.rect.x-50
                Game.player4.rect.y = Game.mini_portal2.rect.y + 30
            if Game.direction4 == "right":
                Game.player4.rect.x = Game.mini_portal2.rect.x + 50
                Game.player4.rect.y = Game.mini_portal2.rect.y - 30